package com.syg.listener4;

import com.syg.event.MyEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

/**
 * 方式4 ,该类无需实现ApplicationListener接口，使用@EventListener修饰具体方法
 */
@Component
public class MyListener4 {
    Logger log = LoggerFactory.getLogger(MyListener4.class);

    @EventListener
    public void listener(MyEvent event) {
        log.info(String.format("%s监听到事件源：%s.", MyListener4.class.getName(), event.getSource()));
    }
}
